//
//  DYArrayDataSource.h
//  ISmartHome
//
//  Created by JM on 15/7/29.
//
//


#import <UIKit/UIKit.h>
#import "Singletion.h"
#import <XPGWifiSDK/XPGWifiSDK.h>

typedef void (^CellConfigureBlock)(id cell, id item);
typedef BOOL(^ItemEuqalBlock)(id);
@interface DYArrayDataSource : NSObject<XPGWifiDeviceDelegate>
singleton_interface(DYArrayDataSource)
@property (nonatomic, strong) NSMutableArray *items;

@property(nonatomic,copy)NSString *userID;
@property(nonatomic,readonly)NSInteger count;
@property(nonatomic,strong)NSMutableArray *removedItems;
- (id)itemAtIndex:(NSUInteger )index;
- (void)setArray:(NSArray *)items;
+ (id)dataSourceWithItems:(NSArray *)aItems cellIdentifier:(NSString *) aID configCellBlock:(CellConfigureBlock) aBLock;
- (void)addItem:(id) aItem ;
- (void)removeItem:(id) aItem ;
- (void)insertObject:(id)aItem atIndex:(NSUInteger)aIndex;
- (BOOL)containsObject:(id)aItem;

- (BOOL)saveItems;
+ (id)dataSourceFromSaveFileWithCellId:(NSString *) aID ConfigCellBlock:(CellConfigureBlock) aBLock;

//- (BOOL)replaceItem:(id)aSourceItem withItem:(id)aItem;
- (void)replaceItemAtIndex:(NSInteger)aIndex withItem:(id)aItem;
- (BOOL)itemSearchWithEqualBlock:(ItemEuqalBlock)aEqualBlock;



- (instancetype)itemWithMacAdress:(NSString *)adress;
@end

@interface DYArrayDataSource(UITableViewDataSource)<UITableViewDataSource>
- (void)connectAndupdateAllDevice;
- (void)setAllxpgDeviceDelegateIsMyself;
- (void)setAllDeviceDelegate:(id<XPGWifiDeviceDelegate>) delegate;
@end
